var t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../utils/util.js")), a = getApp();

Page({
    data: {
        nowTime: "",
        list: "",
        activity_id: "",
        guanz: "",
        exchange_code_id: "",
        set: {}
    },
    onLoad: function(t) {
        if (console.log(t.id), this.setData({
            activity_id: t.id,
            exchange_code_id: t.exchange_code_id || ""
        }), t.scene) {
            var e = decodeURIComponent(t.scene);
            if (e) {
                var i = [];
                i = e.split(",");
                for (var n = 0; n < i.length; n++) {
                    var o;
                    "mid" == (o = i[n].split("="))[0] && a._setMid(o[1]), "id" == o[0] && this.setData({
                        activity_id: o[1]
                    });
                }
            }
        }
        this.getList(), this.getrenshu(), this.getAttention();
    },
    goshouye: function() {
        wx.reLaunch({
            url: "/packageC/Myshaky/activityHome/activityHome"
        });
    },
    goMy: function() {
        wx.navigateTo({
            url: "/packageC/Myshaky/Myindex/Myindex"
        });
    },
    getAttention: function() {
        var t = a.getNetAddresss("plugin.activity-apply.api.activity.isAttention"), e = this;
        a._getNetWork({
            url: t,
            data: {
                activity_id: e.data.activity_id
            },
            success: function(t) {
                var i = t.data;
                1 == i.result && (console.log(i), a._isTextEmpty(i.data) ? e.setData({
                    guanz: 0
                }) : e.setData({
                    guanz: i.data.is_attention
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    goGz: function(t) {
        console.log(wx.getStorageSync("yz_uid"));
        var e = a.getNetAddresss("plugin.activity-apply.api.activity.attention"), i = this;
        a._getNetWork({
            url: e,
            data: {
                activity_id: i.data.activity_id,
                member_id: wx.getStorageSync("yz_uid")
            },
            success: function(t) {
                var a = t.data;
                1 == a.result && (console.log(a), wx.showToast({
                    title: a.msg,
                    duration: 500,
                    icon: "none"
                }), i.setData({
                    guanz: !i.data.guanz
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    goBm: function(t) {
        this.data.count >= this.data.list.limit ? wx.showToast({
            title: "报名人数已满",
            duration: 1500,
            icon: "none"
        }) : this.data.exchange_code_id ? wx.navigateTo({
            url: "/packageC/Myshaky/enroll/enroll?id=" + t.currentTarget.id + "&fid=" + this.data.form_id + "&exchange_code_id=" + this.data.exchange_code_id
        }) : wx.navigateTo({
            url: "/packageC/Myshaky/enroll/enroll?id=" + t.currentTarget.id + "&fid=" + this.data.form_id
        });
    },
    gobmqk: function(t) {
        console.log(t.currentTarget.dataset.id);
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageC/Myshaky/Registration/Registration?id=" + a
        });
    },
    goMyind: function(t) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), a = "";
        t && (a = t);
        var e = {
            path: "/packageC/Myshaky/enrollEnter/enrollEnter?id=" + this.data.activity_id + "&mid=" + a
        }, i = this.data.list.has_one_share, n = i.share_title, o = i.share_thumb, s = (i.share_desc, 
        this.data.list.set), d = s.share_title, r = s.share_thumb;
        s.share_desc;
        return e.title = n || d || "", e.imageUrl = o || r || "", e;
    },
    goToAdress: function() {
        var t = this.data.latitude, e = this.data.longitude, i = this.data.list.title, n = a.BMapTransqqMap(parseFloat(e), parseFloat(t));
        wx.openLocation({
            latitude: n.lat,
            longitude: n.lng,
            scale: 18,
            name: i
        });
    },
    goJs: function(t) {
        var a = t.currentTarget.id, e = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageC/Myshaky/lecturerDetail/lecturerDetail?id=" + a + "&&eid=" + e
        });
    },
    getrenshu: function() {
        var t = a.getNetAddresss("plugin.activity-apply.api.activity.getDetails"), e = this;
        a._getNetWork({
            url: t,
            data: {
                activity_id: e.data.activity_id
            },
            success: function(t) {
                var a = t.data;
                1 == a.result && (0 === a.data.data.length ? e.setData({
                    iswu: !0
                }) : e.setData({
                    iswu: !1
                }), e.setData({
                    datalist: a.data
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getList: function() {
        var e = a.getNetAddresss("plugin.activity-apply.api.Activity.getActivity"), i = this;
        a._getNetWork({
            url: e,
            data: {
                activity_id: i.data.activity_id
            },
            success: function(e) {
                var n = e.data;
                if (1 == n.result) {
                    var o = n.data.registration_end_time, s = t.default.formatTimeTwo(o, "Y/M/D h:m:s");
                    n.data.start_time = t.default.formatTimeTwo(n.data.start_time, "Y/M/D h:m:s"), n.data.end_time = t.default.formatTimeTwo(n.data.end_time, "Y/M/D h:m:s");
                    var d = Date.parse(new Date()) / 1e3;
                    n.data.cash <= "0.00" ? i.setData({
                        mf: !0
                    }) : i.setData({
                        mf: !1
                    }), a._isTextEmpty(n.data.has_many_pay_order) ? i.setData({
                        count: "0"
                    }) : i.setData({
                        count: n.data.has_many_pay_order[0].count
                    }), i.setData({
                        list: n.data,
                        nowTime: d,
                        minlisTime: s,
                        form_id: n.data.form_id,
                        longitude: n.data.longitude ? n.data.longitude : "",
                        latitude: n.data.latitude ? n.data.latitude : "",
                        set: n.data.set
                    }), wx.setNavigationBarTitle({
                        title: i.data.list.title
                    });
                }
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});